﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using MediaOwl.Common;
using MediaOwl.Common.ScreenManagement;
using MediaOwl.WebSearch.Resources;

namespace MediaOwl.WebSearch.ViewModels
{
    [Export(typeof(IWorkspace))]
    public sealed class WebSearchViewModel : Workspace<IWorkitem<IWorkspace>>
    {
        #region Constructor
        [ImportingConstructor]
        public WebSearchViewModel([ImportMany(AllowRecomposition = true)] IEnumerable<IWorkitem<WebSearchViewModel>> childScreens)
        {
            ChildScreens = childScreens as IEnumerable<IWorkitem<IWorkspace>>;
            DisplayName = Captions.ModuleTitle;
            Order = 0;
            IconName = Captions.MenuTitle;
            Icon = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri(@"/MediaOwl.WebSearch;component/Resources/Images/WebSearch.png", UriKind.Relative))
            };

            FillItems();
        }
        #endregion  
     

        protected override void OnInitialize()
        {
            base.OnInitialize();

            var msg =
                Show.MessageBox(
                    "No Bing-Id found. In order to use this module, you must enter a Bing-Api-Key into BingDataAccess.resx!")
                    .In<IShell>();

            Run.Coroutine(msg);
        }
    }
}